{extend name="public/base" /}
{block name="css"}
<link href="__INDEX__/css/plugins/iCheck/custom.css" rel="stylesheet">
{/block}
{block name="container"}
<body class="gray-bg">
    <div class="wrapper wrapper-content animated fadeInRight">
        <div class="row">
            <div class="col-sm-12">
                <div class="ibox float-e-margins">
                    <div class="ibox-title">
                        <h5>编码列表</h5>
                        <div style="float: right;">
                            <!-- <a  class="btn btn-w-m btn-info" href="{:url('index/clothes/create')}">添加编码</a> -->
                        </div>
                    </div>
                    <div class="ibox-content">
                        <div class="row">
                            <form action="" method="post">
                                <div class="col-sm-3" style="float: right;">
                                    <div class="input-group">
                                        <input type="text" placeholder="请输入名称或者条码编号" name="name" class="input-sm form-control"> <span class="input-group-btn">
                                            <button type="submit" class="btn btn-sm btn-primary"> 搜索</button> </span>
                                        </div>
                                    </div>
                                </form>
                                    <div class="col-sm-8">
                                        <div class="input-group" >
                                            <button class="btn btn-sm btn-primary" onclick="export_data()">导出数据</button>
                                        </div>
                                    </div>
                            </div>
                            <div class="table-responsive">
                                <table class="table table-striped">
                                    <thead>
                                        <tr>
                                            <th></th>
                                            <th>序号</th>
                                            <th>名称</th>
                                            <th>条码编号</th>
                                            <th>所属季节</th>
                                            <th>所属品类</th>
                                            <th>颜色</th>
                                            <th>号型</th>
                                            <th>价格</th>
                                            <th>面料编号</th>
                                            <th>面料属性</th>
                                            <th>数量</th>
                                            <th>状态</th>
                                            <th>操作</th>

                                        </tr>
                                    </thead>
                                    <tbody>
                                     {volist name="list" id="vo"}
                                     <tr>
                                        <td>
                                          <!-- <input type="checkbox" class="i-checks">-->
                                          <input type="checkbox" class="i-checks"  name="input" value="{$vo.id}"> 
                                      </td>
                                      <td>{$vo.id}</td>
                                      <td>{$vo.name}</td>
                                      <td>{$vo.code}</td>
                                      <td>{$vo.season}</td>
                                      <td>{$vo.category}</td>
                                      <td>{$vo.color}</td>
                                      <td>{$vo.size}</td>
                                      <td>&yen;{$vo.price}</td>
                                      <td>{$vo.ml_num}</td>
                                      <td>{$vo.ml_style}</td>
                                      <td>{$vo.num}个</td>
                                      <td>
                                         {if condition="$vo['status'] eq 1"} 
                                         <a href="javascript:;"><span class="badge badge-success" title="已处理">已处理</span></a>
                                         {else /}
                                         <a href="javascript:;"  onclick="updateStatus({$vo.id})" title="未处理"><span class="badge badge-danger">未处理</span></a>
                                         {/if}  
                                     </td>
                                     <td> 
                                        <!-- <a data-toggle="modal"  href="#modal-form_yundan" onclick="getInfo({$vo['code']})" title="导出数据"> -->
                                        <a href="{:url('index/clothes/exportOne',array('id'=>$vo['id']))}" title="导出数据">  
                                          <i class="iconfont icon-daochu"></i></a>
                                        &emsp;
                                        <a href="javascript:;" onclick="delcode({$vo['id']})" title="删除"><i class="iconfont icon-shanchu"></i></a></td>
                                    </tr>
                                    {/volist}
                                </tbody>
                            </table>
                            <div style="float: right;">
                               {$page}
                           </div>
                       </div>

                   </div>
               </div>
           </div>

       </div>
   </div>

   <div id="modal-form_yundan" class="modal fade" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-body">
                <div class="row">
                    <div class="col-sm-12 b-r">
                        <h3 class="m-t-none m-b">添加数量：</h3>
                        <form role="form" action="{:url('index/clothes/addnum')}" method="post">
                            <div class="form-group">
                                <input type="name" placeholder="请填入数量" class="form-control" id="reaon" name="num">
                                <input type="hidden" id="orderid_yun" name="code" value="">
                            </div>
                            <div>
                                <button class="btn btn-sm btn-primary pull-right m-t-n-xs" type="submit"><strong>提交</strong>
                                </button>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
{/block}
{block name="js"}
<!-- Peity -->
<script src="__INDEX__/js/plugins/peity/jquery.peity.min.js"></script>

<!-- 自定义js -->
<script src="__INDEX__/js/content.js?v=1.0.0"></script>


<!-- iCheck -->
<script src="__INDEX__/js/plugins/iCheck/icheck.min.js"></script>

<script>
    $(document).ready(function () {
        $('.i-checks').iCheck({
            checkboxClass: 'icheckbox_square-green',
            radioClass: 'iradio_square-green',
        });
    });
    function getInfo(id)
    {
        $('#orderid_yun').val(id);
    }
    /*导出excel*/
    function export_data()
    {
        var attr = '';
        $.each($('input:checkbox'),function(){
            if(this.checked){
                attr += $(this).val()+',';
            }
        });
        attr=attr.substring(0,attr.length-1);
        if(attr.length<1)/*说明没有选择数据*/
        {
            swal({   
                title: "没有导出数据",   
                text: "",   
                type: "error",  
            });
        }else{
            window.location.href = '/index/clothes/excel/attr/'+attr;
           // alert(123);
        }
    }
</script>
<script>
        function updateStatus(id)
        {
            swal({   
                title: "确定要修改状态吗?",   
                text: "确认将修改本条数据的状态!",   
                type: "warning",   
                showCancelButton: true,    
                confirmButtonText: "确认", 
                cancelButtonText: '取消',
                closeOnConfirm: false
            },function(){
                $.post('{:url("index/clothes/updateStatus")}', {id: id}, function(data) {
                    if(data == 1){
                     swal({
                        title: "修改成功",
                        text: "",
                        type: "success"
                    });
                     window.location.reload(); 
                 }else{
                   swal({
                    title: "修改失败",
                    text: "",
                    type: "error"
                });
               }
           });
            });
        }
</script>
<script>
        function delcode(id)
        {
          swal({   
            title: "确定要删除数据?",   
            text: "确认将删除该条数据!",   
            type: "warning",   
            showCancelButton: true,    
            confirmButtonText: "确认", 
            cancelButtonText: '取消',
            closeOnConfirm: false
        }, function(){   
          $.post('{:url("index/clothes/delcode")}', {'id':id}, function(data) {
            if(data.sta == -1 ){
                swal({
                    title: "权限不足",
                    text: "",
                    type: "error"
                });
            }else if(data.sta == 1){
               swal({
                title: "删除成功",
                text: "",
                type: "success"
            });
               window.location.reload();
           }else{
            swal({
                title: "删除失败",
                text: "",
                type: "error"
            });                
        }
    });
      });
      }
</script>

{/block}